<template>
  <div class="line_container">
    <div class="top">
      <div class="left">
        <p>未来7天游客量趋势</p>
        <p class="left_bg"></p>
      </div>
    </div>
    <div class="line" ref="line"></div>
  </div>
</template>
<script setup lang="ts">
import * as echarts from "echarts";
import { ref, onMounted } from "vue";
//获取图形图标的节点
let line = ref();
onMounted(() => {
  let mycharts = echarts.init(line.value);
  //设置配置项
  mycharts.setOption({
    //标题组件
    title: {
      text: "访问量",
    },
    //x|y轴
    xAxis: {
      type: "category",
      //两侧不留白
      boundaryGap: false,
      //分割线不要
      splitLine: {
        show: false,
      },
      data: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
      //轴线的设置
      axisLine: {
        show: true,
      },
      //刻度
      axisTick: {
        show: true,
      },
    },
    yAxis: {
      splitLine: {
        show: false,
      },
      //轴线的设置
      axisLine: {
        show: true,
      },
      //刻度
      axisTick: {
        show: true,
      },
    },
    grid: {
      left: 120,
      top: 20,
      right: 40,
      bottom: 40,
    },
    //系列
    series: [
      {
        type: "line",
        data: [120, 1240, 66, 2299, 321, 890, 1200],
        //平滑曲线的设置
        smooth: true,
        //区域填充样式
        areaStyle: {
          color: {
            type: "linear",
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: "#87CEFA", // 0% 处的颜色
              },
              {
                offset: 1,
                color: "blue", // 100% 处的颜色
              },
            ],
            global: false, // 缺省为 false
          },
        },
      },
    ],
  });
});
</script>
<style scoped lang="scss">
.line_container {
  background: url(../../../../assets/images/screen/dataScreen-main-cb.png)
    no-repeat;
  background-size: 100% 100%;
  margin: 0 16px;

  .top {
    display: flex;
    justify-content: space-between;
    height: 54px;
    padding: 10px;
    color: white;

    .left {
      .left_bg {
        width: 68px;
        height: 8px;
        margin-top: 12px;
        background: url(../../../../assets/images/screen/dataScreen-warn-bg.png);
        background-size: 100% 100%;
      }
    }
  }

  .line {
    height: calc(100% - 56px);
  }
}
</style>
